﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_ManagedSystemElement class is the base class for the system element hierarchy. Any distinguishable system component is a candidate for inclusion in this class. Examples include software components, such as files; devices, such as disk drives and controllers; and physical components, such as chips and cards.
    /// </summary>
    public class CIM_ManagedSystemElement
    {

        private string _Caption;
        private string _Description;
        private Nullable<DateTimeOffset> _InstallDate;
        private string _Name;
        private string _Status; //TODO Enums


        /// <summary>
        /// Short textual description of the object.
        /// </summary>
        public string Caption { get { return _Caption; } }

        /// <summary>
        /// Textual description of the object.
        /// </summary>
        public string Description { get { return _Description; } }

        /// <summary>
        /// Date and time the object was installed. This property does not need a value to indicate that the object is installed.
        /// </summary>
        public Nullable<DateTimeOffset> InstallDate { get { return _InstallDate; } }

        /// <summary>
        /// Label by which the object is known. When subclassed, this property can be overridden to be a key property.
        /// </summary>
        public string Name { get { return _Name; } }

        /// <summary>
        /// String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive).
        /// Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states.
        /// </summary>
        public string Status { get { return _Status; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_ManagedSystemElement(ManagementBaseObject mbo)
        {
            _Caption = mbo.GetStringValue("Caption");
            _Description = mbo.GetStringValue("Description");
            _InstallDate = mbo.GetDateTimeOffsetValue("InstallDate", Consts.DateTimeFormat);
            _Name = mbo.GetStringValue("Name");
            _Status = mbo.GetStringValue("Status");
        }

    }
}
